<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				<div class="widget-head am-cf">
					<div class="widget-title am-fl">编辑用户</div>
					<div class="widget-function am-fr">
						<a href="javascript:;" class="am-icon-cog"></a>
					</div>
				</div>
				
				<div class="widget-body am-fr">
					<form class="am-form tpl-form-line-form" id="userForm"
						method="post">
						
 						<input type="hidden" name="id" th:value="${user.id}"
							required="required" />
						
						<div class="am-form-group">
							<label for="account" class="am-u-sm-2 am-form-label">账号：</label>
							<div class="am-u-sm-10">
								<input type="text" id="account" class="tpl-form-input" placeholder="请输入账号"  th:value="${user.accountName}"   name="accountName" readonly="readonly"/> 
							</div>
						</div>	
						
						<div class="am-form-group">
							<label for="name" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>姓名：</label>
							<div class="am-u-sm-10">
								<input type="text" id="name" class="tpl-form-input" placeholder="请输入姓名"  th:value="${user.userName}"  name="userName" /> 
							</div>
						</div>	

                       <div class="am-form-group">
							<label for="name" class="am-u-sm-2 am-form-label">邮箱：</label>
							<div class="am-u-sm-10">
								<input type="text" id="email" class="tpl-form-input"  name="email" th:value="${user.email}"/> 
							</div>
						</div>	
						
						
					<div class="am-form-group ">
							<label for="role" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>所属角色：</label>
							<div class="am-u-sm-10 ">	
								<select id="role" name="role.id" data-am-selected="{searchBox: 1}"  >
									<option th:each="role  : ${rolelist}" 
									     th:value="${role.id}" 
									     th:text="${role.name}"
									     th:selected="${user.role.id}==${role.id}"
									     ></option>
								</select>
							
							</div>
						</div>


					<div class="am-form-group ">
							<label for="companyId" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>所属公司：</label>
							<div class="am-u-sm-10 ">	
								<select id="companyId" name="companyId" data-am-selected="{searchBox: 1}"  >
									<option th:each="company  : ${companyList}" 
									     th:value="${company.id}" 
									     th:text="${company.companyName}"
									     th:selected="${user.companyId}==${company.id}"
									     ></option>
								</select>
							
							</div>
						</div>


                     <div class="am-form-group " th:if="${deptinfo==1}">
							<label for="deptId" class="am-u-sm-2 am-form-label" >所属部门：</label>
							<div class="am-u-sm-10 ">	
								<select id="deptId" name="deptId" data-am-selected="{searchBox: 1}"  >
									<option th:each="dept  : ${deptList}" 
									     th:value="${dept.id}" 
									     th:text="${dept.deptName}"
									      th:selected="${user.deptId}==${dept.id}"
									     ></option>
								</select>
							</div>
						</div>




                     <div class="am-form-group">
							<label for="isValid" class="am-u-sm-2 am-form-label"><span class="text-red"> *</span>状态：</label>
							<div class="am-u-sm-10">
								<select id="isValid" name="isValid" th:if="${user.isValid == 1}">
									<option value="1" selected="selected">启用</option>
									<option value="0">停用</option>
								</select>
								<select id="isValid" name="isValid" th:if="${user.isValid == 0}">
									<option value="1">启用</option>
									<option value="0" selected="selected">停用</option>
								</select>
							</div>
						</div>

						<div class="am-form-group">
							<label for="desc" class="am-u-sm-2 am-form-label">用户描述： </label>
							<div class="am-u-sm-10">
								<input type="text" id="desc" class="tpl-form-input" placeholder="请输入用户描述" name="description"  th:value="${user.description}"  /> 
							</div>
						</div>	 


						<div class="am-form-group">
							<div class="am-u-sm-10 am-u-sm-push-2">
								<button type="button"
									onclick="javascript:$('#userForm').submit();"
									class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
								<button type="button" onclick="loadPage('user/listUI')"
									class="am-btn am-btn-success tpl-btn-bg-color-success ">返回</button>
							</div>
						</div>
					</form>
				</div>
				
				
				
				
			</div>
		</div>
	</div>

	</div>
	<script th:inline="javascript">
	<![CDATA[
	//$('select').selected();
	validateUserForm();
	function validateUserForm(){    
	    $('#userForm').validate({
	        errorElement : 'span',
	        errorClass : 'am-icon-times',
	        focusInvalid : true,
	        onkeyup:false,
	        ignore : "",
	        rules : {
	            accountName : {
	                required : true,
	                maxlength : 50
	            },
	            password : {
	                required : true,
	                minlength : 6,
	                maxlength : 50
	            },
	            repassword : {
	                required : true,
	                minlength : 6,
	                equalTo : "#password",
	                maxlength : 50
	            },
	            userName : {
	                required : true,
	                maxlength : 50
	            },
	            "role.id" : {
	                required : true
	            },
	            email: {
	            	email: true,
	            	maxlength : 50
	            },
	            description : {
	            	maxlength : 50
	            }
	        },
	        messages : {
	            accountName : {
	                required : "请填写账号",
	            },
	            password : {
	                required : "请填写密码",
	                minlength : "密码长度不能少于6个字符"
	            },
	            repassword : {
	                required : "请再次填写密码",
	                minlength : "密码长度不能少于6个字符",
	                equalTo : "两次填写密码不一致，请重新填写"
	            }, email:{
	            	 email: "请输入一个正确的邮箱",
	            },userName :{
	            	 required :  "请填写真实姓名",
	            },
	            "role.id" : {
	            	 required :  "请选择角色"
	            }
	        },
	        submitHandler : function(form) {
	        	commit('userForm', 'user/save', 'user/listUI');
	        }
	    });
	}
		]]>
	</script>